package com.shop.core.util;

import java.io.IOException;

import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import com.shop.core.constants.BaseConstants;

/**
 * Servlet工具类
 * 
 * @author Shine
 * @date 2016年6月20日14:55:22
 * @version 1.0
 *
 */
public class ServletUtil {
	/**
	 * 页面回写JSON数据
	 */
	public static void writeTOPage(ServletResponse response, Object psJsonData) {
		response.setCharacterEncoding(BaseConstants.Encoding.UTF8);
		response.setContentType(BaseConstants.DataType.TEXT_JSON);
		try {
			response.getWriter().print(psJsonData);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 获取request请求的方法全部路径
	 */
	public static String getRequestURL(HttpServletRequest request) {
		return request.getRequestURL().toString();
	}

}
